import CryptoJS from 'crypto-js'

const KEY = 'innovation'

/*
* message:需要解密的字符串，
* key： 密钥（加密解密密钥同一个）
*/
export const decryptDes = (ciphertext) => {
  const keyHex = CryptoJS.enc.Utf8.parse(KEY)
  // direct decrypt ciphertext
  const decrypted = CryptoJS.DES.decrypt({
    ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
  }, keyHex, {
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  })
  return decrypted.toString(CryptoJS.enc.Utf8)
}
